﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="myCustomerEdit.aspx.cs"
    Inherits="PeisongWeb.admin.myCustomerEdit" %>

<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Register TagName="menu" Src="controls/menu.ascx" TagPrefix="uc2" %>
<%@ Register TagName="top" Src="controls/top.ascx" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>我的客户查看 - 想购网长期采购物流配送系统</title>
    <!--#include file="style.inc"-->

    <script type="text/javascript" language="javascript" src="../app_common/scripts/jquery-cn.js"></script>

    <script type="text/javascript">
        function chkFm() {
            if ($("#txt_CompanyName").val() == "") {
                alert("请输入公司名！");
                document.getElementById("txt_CompanyName").focus();
                return false;
            }
            var hasChecked = false;
            if ($("#hd_type").val() == "") {

                /*校验类别*/

                $("input[id^='rad_Type']").each(function(i, n) {
                    if ($(n).attr("checked")) {
                        $("#hd_type").val($(n).val());
                        hasChecked = true;
                    }
                });
            }
            else
                hasChecked = true;

            if (!hasChecked) {
                alert("请选择类别");
                return false;
            }
            else {
                /*判断采购商供应范围*/
                var range = "";
                $("input[id^='chk_category_']").each(function(i, n) {
                    if ($(n).attr("checked")) {
                        range += $(n).val() + ",";
                    }
                });
                $("#hd_buyRange").val(range);


                //判断供应商
                if ($("#hd_type").val() == "1") {

                    if ($("#txt_Location").val() == "") {
                        alert("请输入摊位地址！");
                        document.getElementById("txt_Location").focus();
                        return false;
                    }

                    if ($("#chk_CooperateType1").attr("checked") == false && $("#chk_CooperateType2").attr("checked") == false) {
                        alert("请选择合作模式！");
                        return false;
                    }
                    if ($("#chk_CooperateType1").attr("checked")) {
                        $("#hd_cooperateType").val("1");
                    }
                    if ($("#chk_CooperateType2").attr("checked")) {
                        $("#hd_cooperateType").val("2");
                        var cooperatePercent = $("#txt_cooperatePercent").val();
                        if (cooperatePercent == "") {
                            alert("请输入提成！");
                            document.getElementById("txt_cooperatePercent").focus();
                            return false;
                        }
                        //判断数字
                        if (!isNumberFlag(cooperatePercent, ".")) {

                            alert("无效的提成！");
                            document.getElementById("txt_cooperatePercent").focus();
                            return false;
                        }
                    }

                }
                //判断采购商
                if ($("#hd_type").val() == "2") {

                    //判断采购商类别
                    var buyIsCheck = false;
                    //if ($("#hd_buyType").val() == "") {

                    /*校验类别*/

                    $("input[id^='rad_buyerType']").each(function(i, n) {
                        if ($(n).attr("checked")) {
                            $("#hd_buyType").val($(n).val());
                            buyIsCheck = true;
                            //alert($(n).val());
                        }
                    });
                    //}
                    //else
                    //    buyIsCheck = true;

                    if (!buyIsCheck) {
                        alert("请选择采购商类别");
                        return false;
                    }

                    var txtAutoPercent = $("#txtAutoPercent").val();
                    if (txtAutoPercent == "") {
                        alert("请输入自动增加比例！");
                        document.getElementById("txtAutoPercent").focus();
                        return false;
                    }
                    //判断数字
                    if (!isNumberFlag(txtAutoPercent, ".")) {

                        alert("无效的自动增加比例！");
                        document.getElementById("txtAutoPercent").focus();
                        return false;
                    }
                }


            }




            if ($("#txt_CompanyNo").val() == "") {
                alert("请输入公司编号！");
                document.getElementById("txt_CompanyNo").focus();
                return false;
            }

            if ($("#ddl_Area").val() == "") {
                alert("请输入区域！");
                document.getElementById("ddl_Area").focus();
                return false;
            }

            if ($("#txt_Address").val() == "") {
                alert("请输入详细地址！");
                document.getElementById("txt_Address").focus();
                return false;
            }

            if ($("#ddl_Employees").val() == "") {
                alert("请选择公司规模！");
                document.getElementById("ddl_Employees").focus();
                return false;
            }

            if ($("#txt_Contact").val() == "") {
                alert("请输入公司联系人！");
                document.getElementById("txt_Contact").focus();
                return false;
            }



            if ($("#txt_Mobile").val() == "") {
                alert("请输入联系人手机！");
                document.getElementById("txt_Mobile").focus();
                return false;
            }

            if ($("#txt_Email").val() != "") {
                var email = $.ajax({
                    url: "customer.ashx?Param=checkvemailformat&email=" + $("#txt_Email").val(),
                    async: false,
                    cache: false
                }).responseText;

                if (email != "1") {
                    alert("EMAIL地址无效,请重新输入");
                    document.getElementById("txt_Email").focus();
                    return false;
                }
            }
            if ($("#txt_Suggest").val() == "") {
                alert("请输入审核意见！");
                document.getElementById("txt_Suggest").focus();
                return false;
            }
            return true;
        }

        function getOption(type) {
            //1：供应商，2：采购商，3：物流商
            if (type == "1") {
                $("#cooperateType").show(); //合作模式显示
                //判断是否显示分成比例
                if ($("#chk_CooperateType2").attr("checked")) {
                    showCooperatePercent();
                }
                else {
                    hideCooperatePercent();
                }
                $("#autoAddPercent").hide();
                $("#li_receiveTime").hide();
                $("#location").show();
                $("#idcard").hide();
                $("#buyerType").hide();
                $("#li_Sales").hide();
                $("#li_eatPerson").hide();
                $("#li_range").show();
            }
            else if (type == "2") {
                $("#cooperateType").hide();  //合作模式隐藏
                hideCooperatePercent();
                $("#autoAddPercent").show();
                $("#li_receiveTime").show();
                $("#location").hide();
                $("#idcard").show();
                $("#buyerType").show();
                $("#li_Sales").show();
                $("#li_eatPerson").show();
                $("#li_range").hide();
            }
            else {
                $("#buyerType").hide();
            }
        }

        function showCooperatePercent() {
            $("#cooperatePercent").show();
        }
        function hideCooperatePercent() {
            $("#cooperatePercent").hide();
        }

        function isNumberFlag(s, spe) {
            var i;
            for (i = 0; i < s.length; i++) {
                // Check that current character is number.
                var c = s.charAt(i);
                if (c != spe) {
                    if (((c < "0") || (c > "9")))
                        return false;
                }

            }
            // All characters are numbers.
            return true;
        }

        function showCustomerInfor() {
            $("#autoAddPercent").show();
            $("#li_receiveTime").show();
            hideCooperatePercent();
            $("#cooperateType").hide();
            $("#location").hide();
            $("#idcard").show();
            $("#buyerType").show();
            $("#li_Sales").show();
            $("#li_eatPerson").show();
            $("#li_score").hide();
            $("#li_range").css('display', 'none');
        }

        function showSupplyInfor(type) {
            $("#cooperateType").show();
            if (type == "2") {
                showCooperatePercent();
            }
            else {
                hideCooperatePercent();
            }
            $("#autoAddPercent").hide();
            $("#li_receiveTime").hide();
            $("#location").show();
            $("#idcard").hide();
            $("#li_Sales").hide();
            $("#li_eatPerson").hide();
            $("#li_score").show()
        }

        function chkScoreText() {
            var score = $("#txt_Score").val();
            if (score == "") {
                alert("请输入您要修改的积分!");
                return false;
            }
            else {
                var initScore = $("#hid_initScore").val();
                if (parseInt(score) > parseInt(initScore)) {
                    alert("对不起，不能大于初始分！");
                    return false;
                }
            }
            return true;
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <ext:ScriptManager ID="ScriptManager1" runat="server" />
    <uc1:top ID="Top1" runat="server" />
    <uc2:menu ID="Menu1" runat="server" />
    <div id="admin_main" style="margin: 10px 0 0 10px;">
        <ext:Panel ID="Panel2" runat="server" Title="我的客户编辑" BodyStyle="padding:5px 5px 0"
            Width="650" Frame="true" ButtonAlign="Center">
            <Body>
                <div id="admin_edit_content">
                    <ul>
                        <li>
                            <label>
                                企业名称 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_CompanyName"></asp:TextBox>
                        </li>
                        <li id="showType" runat="server">
                            <label>
                                企业类别 *
                            </label>
                            <asp:Repeater runat="server" ID="rpt_type">
                                <ItemTemplate>
                                    <input type="radio" onclick="getOption('<%#Eval("xm") %>')" id='rad_Type<%#Eval("xm") %>'
                                        value='<%#Eval("xm") %>' <%#Convert.ToBoolean(Eval("isChecked"))?"checked":"" %>
                                        name="type" /><%#Eval("name") %>
                                </ItemTemplate>
                            </asp:Repeater>
                        </li>
                        <li id="showType2" runat="server">
                            <label>
                                企业类别
                            </label>
                            <asp:Label runat="server" ID="lbl_type"></asp:Label>
                        </li>
                        <li id="buyerType" style="display: none;" runat="server">
                            <label>
                                采购商类别 *
                            </label>
                            <asp:Repeater runat="server" ID="rpt_buyerType">
                                <ItemTemplate>
                                    <input type="radio" id='rad_buyerType<%#Eval("xm") %>' value='<%#Eval("xm") %>' <%#Convert.ToBoolean(Eval("isChecked"))?"checked":"" %>
                                        name="buyerType" /><%#Eval("name") %>
                                </ItemTemplate>
                            </asp:Repeater>
                        </li>
                        <li id="li_Sales" style="display: none;">
                            <label>
                                销售员
                            </label>
                            <asp:DropDownList runat="server" ID="ddl_SalesPerson" DataTextField="username" DataValueField="adminId">
                            </asp:DropDownList>
                        </li>
                        <li id="li_range">
                            <label>
                                商品范围
                            </label>
                            <asp:Repeater runat="server" ID="rpt_CategoryRoot">
                                <ItemTemplate>
                                    <input type="checkbox" id='chk_category_<%#Eval("categoryId") %>' value='<%#Eval("categoryId") %>'
                                        <%#Convert.ToBoolean(Eval("isChecked"))?"checked":"" %> name="type" /><%#Eval("name") %>
                                </ItemTemplate>
                            </asp:Repeater>
                        </li>
                        <li>
                            <label>
                                企业编号 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_CompanyNo" MaxLength="8"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                地 区 *
                            </label>
                            <asp:DropDownList runat="server" ID="ddl_Area" DataTextField="name" DataValueField="xm">
                            </asp:DropDownList>
                        </li>
                        <li>
                            <label>
                                详细地址 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_Address"></asp:TextBox>
                        </li>
                        <li id="location" style="display: none;">
                            <label>
                                摊位号 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_Location"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                固定电话
                            </label>
                            <asp:TextBox runat="server" ID="txt_Phone"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                传真号码
                            </label>
                            <asp:TextBox runat="server" ID="txt_Fax"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                邮政编码
                            </label>
                            <asp:TextBox runat="server" ID="txt_PostCode" MaxLength="6"></asp:TextBox>
                        </li>
                        <li id="li_eatPerson" style="display: none">
                            <label>
                                用餐人数
                            </label>
                            <asp:TextBox runat="server" ID="txt_eatPerson" MaxLength="20"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                联系人 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_Contact"></asp:TextBox>
                        </li>
                        <li id="idcard" style="display: none;">
                            <label>
                                身份证号码
                            </label>
                            <asp:TextBox runat="server" ID="txt_IDCard"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                联系人手机 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_Mobile" MaxLength="11"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                Email
                            </label>
                            <asp:TextBox runat="server" ID="txt_Email"></asp:TextBox>
                        </li>
                        <li>
                            <label>
                                结帐方式
                            </label>
                            <asp:DropDownList runat="server" ID="ddl_PayMethod" DataTextField="name" DataValueField="xm">
                            </asp:DropDownList>
                        </li>
                        <li id="cooperateType" style="display: none;">
                            <label>
                                合作模式
                            </label>
                            <input type="radio" runat="server" onclick="hideCooperatePercent();" id="chk_CooperateType1"
                                name="cooperateType" />
                            浮动价格
                            <input type="radio" runat="server" onclick="showCooperatePercent();" id="chk_CooperateType2"
                                name="cooperateType" />
                            分成价格 </li>
                        <li id="cooperatePercent" style="display: none;">
                            <label>
                                提成
                            </label>
                            <asp:TextBox runat="server" ID="txt_cooperatePercent" Width="30" MaxLength="4"></asp:TextBox>
                            (例：0.30表示30%) </li>
                        <li id="autoAddPercent" style="display: none;">
                            <label>
                                自动增加比例
                            </label>
                            <asp:TextBox runat="server" ID="txtAutoPercent" Text="0" Width="30" MaxLength="4"></asp:TextBox>
                            (例：0.30表示30%) </li>
                        <li id="li_receiveTime" style="display: none">
                            <label>
                                送货时间 *</label>
                            <asp:DropDownList runat="server" ID="ddl_receiveTime" DataTextField="name" DataValueField="xm">
                            </asp:DropDownList>
                        </li>
                        <li>
                            <label>
                                是否审核
                            </label>
                            <input runat="server" type="checkbox" id="chx_isCheck" name="check" />是</li>
                        <li>
                            <label>
                                审核意见 *
                            </label>
                            <asp:TextBox runat="server" ID="txt_Suggest" TextMode="MultiLine" Width="300" Height="50"></asp:TextBox>
                        </li>
                        <li id="li_score" style="display: none">
                            <label>
                                积分
                            </label>
                            <asp:Label runat="server" ID="lbl_score"></asp:Label>分 <a href="javascript:showWin();">
                                修改积分</a> </li>
                        <li>
                            <label>
                                是否启用周报价</label>
                            <asp:CheckBox runat="server" ID="chkWeeklyPrice" />
                        </li>
                        <li>
                            <label>
                                &nbsp;
                            </label>
                            <!--
                            <span style="<%=power>=2?"": "display:none" %>">
                                <asp:Button runat="server" ID="btn_Save" Text="保 存" OnClick="btn_Save_Click" OnClientClick="return chkFm()" />
                            </span>
                            -->
                            <input type="button" id="btn_Return" value="返 回" onclick="window.location.href='myCustomerList.aspx'" />
                            <input type="hidden" id="hd_buyRange" runat="server" />
                            <input type="hidden" id="hd_cooperateType" runat="server" />
                            <input type="hidden" id="hd_type" runat="server" />
                            <input type="hidden" id="hd_buyType" runat="server" />
                        </li>
                    </ul>
                </div>
            </Body>
        </ext:Panel>
    </div>
    <input runat="server" type="hidden" id="hid_initScore" />
    </form>
</body>
</html>
